package com.jimmy.ioc.bean;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @version 1.0
 * @ ClassName Dog
 * <p> 加入了IOC容器供其它方法调用IOC容器
 * @ author JIMMY
 * @ Date 2020/12/7 0007 下午 12:15
 */
@Component
public class Dog implements ApplicationContextAware {
    private ApplicationContext applicationContext;
    public Dog() {
        System.out.println("dog construct");
    }
    @PostConstruct
    public void init(){
        System.out.println("dog init");
    }
    @PreDestroy
    public void destroyed(){
        System.out.println("dog destroyed");
    }

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
